- Quiz III: 
Thursday April 09
I will drop the two lowest grades among the quizzes/classworks
Material to be announced later

- Exam II: 
Thursday April 16
Material to be announced later

- Case study:
Read data from a file (Scanner: iterator) ---> hasNext, next
Write data to a file (java.io package: a) FileWriter; b) BufferedWriter; c) PrintWriter)

- Problem solving: 

1. Checking whether an int is a power of 2

int n ==> boolean value: true if n is a power of 2; false, otherwise

Optimal solution: time complexity O(1) space complexity O(1)
Hint: the optimal solution involves bitwise operators (&)

n = 2^a for some int value a ===> log2(n) = a (whole number)

Application#1: IsPowerOf2

2. Fibonacci sequence
pos (referred to as n)
0	1	2	3	...

0	1	1	2	3 ...

fib(n) = 

fib(0) = 0
fib(1) = 1

Many different solutions: a) Recursive (brute force); 
b) Uses memoization (caching); c) Dynamic programming

0		1		1				2
prevprev	prev		current = prevprev + prev
		prevprev	prev				current = prevprev + prev

Application#2: Fibonacci

- Scanner problem

Application#3: ScannerProblem.java

- Null pointer problem
Application#4: NullPointerProblem.java

- How to compare double values?

IsWholeNumber

Enter n: 4.5
4.5 is not a whole number

Enter n: 4
4 is a whole number

double val1, val2; // Initialized properly 
floating point error

a. Double.compare(val1, val2) == 0
b. Math.abs(val1 - val2) < E-10

Is whole (simplest way) ===> val % 1 == 0

Codeforces
----------------------------------------------------------

Chapter 6 (Older version of the book)
Chapter 7 (Newer version of the book)

Topic#1: static?

Application#5: 
Driver class: MultiSlogans.java
Helper class: Slogan.java

Aim: Create multiple Slogan objects and then print their count out

Slogan slg1 = new Slogan("Just Do It");			count: 3
slg1:
phrase = "Just Do It"


Slogan slg2 = new Slogan("Live free or die");
slg2:
phrase = "Live free or die"

Slogan slg3 = new Slogan("Do not worry, be happy");
slg3: 
phrase = "...."









































